package com.crealth.memcached;

import java.util.List;

import com.crealth.db.ConsumerDb;
import com.crealth.model.ConsumerFollowupModel;

public class ConsumerFollowupCached {
	private static final String followupKeyPrefix = "followup_csmid_";
	
	@SuppressWarnings("unchecked")
	public static List<ConsumerFollowupModel> selectConsumerFollowup(int consumerID) {
		String key = followupKeyPrefix + consumerID;
		Object obj = MemcachedMgr.cachedClient.get(key);
		List<ConsumerFollowupModel> followupls = null;
		if (obj != null) {
			followupls = (List<ConsumerFollowupModel>)obj;
		}
		else {
			followupls = ConsumerDb.selectConsumerFollowup(consumerID);
			if (followupls != null) {
				MemcachedMgr.cachedClient.set(key, followupls);
			}
		}
		
		return followupls;
	}
	
	public static void deleteCached(int consumerID) {
		String key = followupKeyPrefix + consumerID;
		MemcachedMgr.cachedClient.delete(key);
	}
	
}
